# coding: utf-8
from marshmallow import Schema, fields
from model.model_base import Base
from sqlalchemy import Column, String, Integer, Numeric, Date, DateTime


class StationMonRep(Base):
    # 供电所指标月报
    __tablename__ = 'StationMonRep'
    bureauid = Column(String(2), primary_key=True, comment='供电局编号')
    bureauname = Column(String(50), nullable=True, comment='供电局名称')
    stationid = Column(String(2), primary_key=True, comment='供所编号')
    stationname = Column(String(50), nullable=True, comment='供电所名称')
    sctrans_suc_rate = Column(Numeric(5,2), nullable=True, comment='专公变采集成功率')
    sctrans_num = Column(Integer, nullable=True, comment='专公变采集成功率排名')
    lowvolta_suc_rate = Column(Numeric(5,2), nullable=True, comment='低压采集成功率')
    lowvolta_num = Column(Integer, nullable=True, comment='低压采集成功率排名')
    less98 = Column(Integer, nullable=True, comment='采集成功率低于98台区数量')
    less98_num = Column(Integer, nullable=True, comment='采集成功率低于98台区数量排名')
    phovolta_suc_rate = Column(Numeric(5,2), nullable=True, comment='光伏采集成功率')
    phovolta_num = Column(Integer, nullable=True, comment='光伏采集成功率排名')
    import_time = Column(DateTime, nullable=True, comment='导入时间')
    monthnum = Column(Date, primary_key=True, comment='所属月份')


class StationMonRepSchema(Schema):
    bureauid = fields.String()
    bureauname = fields.String()
    stationid = fields.String()
    stationname = fields.String()
    sctrans_suc_rate = fields.Number()
    sctrans_num = fields.Integer()
    lowvolta_suc_rate = fields.Number()
    lowvolta_num = fields.Integer()
    less98 = fields.Integer()
    less98_num = fields.Integer()
    phovolta_suc_rate = fields.Number()
    phovolta_num = fields.Integer()
    import_time = fields.DateTime(format="%Y-%m-%d %H:%M:%S.%f")
    monthnum = fields.Date()


stationMonRepSchema = StationMonRepSchema()


